﻿using Microsoft.Xna.Framework.Input;
using OilRigSumoWrestlers.Commands;
using RaptorEngine.Managers;

namespace OilRigSumoWrestlers.KeyBindings
{
    class PlayerMenuBindings : KeyBindingCollection
    {
        public PlayerMenuBindings(LogicalPlayerIndex player)
        {
            if(player.Equals(LogicalPlayerIndex.One))
            {
                PlayerOneBindings(player);
            }
            else if (player.Equals(LogicalPlayerIndex.Two))
            {
                PlayerTwoBindings(player);
            }
        }

        private void PlayerOneBindings(LogicalPlayerIndex player)
        {
            bindings.Add(GameConstant.MENU_FORWARD + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Key = Keys.Enter,
                Button = Buttons.A,
                ExtraButton = Buttons.Start
            });

            bindings.Add(GameConstant.MENU_BACK + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Key = Keys.Escape,
                Button = Buttons.B
            });

            bindings.Add(GameConstant.MENU_NEXT + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Key = Keys.S,
                Button = Buttons.LeftThumbstickDown,
                ExtraButton = Buttons.DPadDown
            });

            bindings.Add(GameConstant.MENU_PREVIOUS + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Key = Keys.W,
                Button = Buttons.LeftThumbstickUp,
                ExtraButton = Buttons.DPadUp
            });
        }

        private void PlayerTwoBindings(LogicalPlayerIndex player)
        {
            bindings.Add(GameConstant.MENU_FORWARD + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Key = Keys.Enter,
                Button = Buttons.A,
                ExtraButton = Buttons.Start
            });

            bindings.Add(GameConstant.MENU_BACK + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Key = Keys.LeftControl,
                Button = Buttons.B
            });

            bindings.Add(GameConstant.MENU_NEXT + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Key = Keys.Down,
                Button = Buttons.LeftThumbstickDown,
                ExtraButton = Buttons.DPadDown
            });

            bindings.Add(GameConstant.MENU_PREVIOUS + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Key = Keys.Up,
                Button = Buttons.LeftThumbstickUp,
                ExtraButton = Buttons.DPadUp
            });
        }
    }
}
